import { version } from "os";

namespace Study401 {
  type Person = {
    name: string;
    age: number;
    ispload: boolean;
  };
  type PersonKey = keyof Person // "name" | "age" | "ispload"

  interface Person2{
    name: string;
    age: number;
    ispload: boolean;
  }
  type PersonKey2 = keyof Person2  // name | age | ispload

  // 类的属性名
  class Person3{
    constructor(
      public name: string,
      public age: number,
      public isActive:boolean
    ){}
  }
  // 获取类的属性名
  type PersonKey3 = keyof Person3  //name|age|isActive
  

  // 遍历对象的属性
  // 可以使用keyof结合in关键字，来遍历对象类型的所有键
  type Person4 = {
    name: string;
    age: number;
    isEmployed: boolean;
  };
  type Person4Kexuan = {
    [key in keyof Person4]?: string;
  }
  type Person4Kexuan2 = {
    name?: string | undefined;
    age?: string | undefined;
    isEmployed?: string | undefined;
  }
  type Person4Kexuan3 = {
    name?: string | undefined;
    age?: number | undefined;
    isEmployed?: boolean | undefined;
  }
  type Person4Kexuan444 = {
   readonly[K in keyof Person4]:Person4[K]
  }

  const settings = {
    theme: "dark",
    version: "1.0",
    userCache: true,
  };
  // type settinggsType="theme"|"verson"|"userCache"
  type settinggsType=keyof typeof settings
}